<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="com.infomanage.enums.*" %>
<%@page import="com.infomanage.po.*" %>
<%@page import="com.infomanage.vo.*" %>
<%@page import="com.infomanage.service.assess.*"%>
<%  response.addDateHeader("Expires", 0);response.setHeader("Pragma","no-cache"); response.setHeader("Cache-Control","no-cache");%>
<%
    request.setCharacterEncoding("UTF-8");
	String itemId = request.getParameter("itemId");
    if(itemId == null) itemId = "";
    
    AssessPersonItem item = AssessPersonService.loadAssessPerson(request, response, out);
    int deptId = -1;
    int personId = -1;
    String deptname = "";
    String personname = "";
    String assessTime = "";
    float deductPoints = 0;
    String description = "";
    if(item != null) {
    	AssessPerson bean = item.getBean();
		Department dept = item.getDept();
		Person person = item.getPerson();
	    deptId = bean.getDeptId();
	    deptname = dept.getPath();
	    assessTime = bean.getAssessTime();
	    deductPoints = bean.getDeductPoints();
	    personId = person.getPersonId();
	    personname = person.getName();
	    description = bean.getDescription();
    } 
%>

<html>
<head>
	<title>队员考核</title>
	<link href="../../css/table.css" rel="stylesheet" type="text/css">
	<link href="../../css/calendar.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="../../js/calendar.js"></script>
	<script type="text/javascript" src="../../js/common.js"></script>
	<script type="text/javascript">
	 function init() {
		   if("" != "<%=itemId%>") { // 修改
			   form1.deptId.value = "<%=deptId%>";
			   form1.deptname.value = "<%=deptname%>";
			   form1.personId.value = "<%=personId%>";
			   form1.personname.value = "<%=personname%>";
			   form1.assessTime.value = "<%=assessTime%>";
			   form1.description.value = "<%=description%>";
			   
		   }
	   }
	   // 提交
	   function doSubmit(){
	   		//if(validate()){
	   		//	return;
	   		//}
		 	if("" == "<%=itemId%>") {
		 		form1.actionType.value = "add";
			}else {
		 		form1.actionType.value = "modify";
			}
		 	form1.submit();
	   }

		function validate(){
	   		if(form1.deptId.value == ""){
	   			alert("单位不能为空！");
	   			return true;
	   		}

	   		if(form1.personId.value == ""){
	   			alert("考核人员不能为空！");
	   			return true;
	   		}

	   		if(form1.assessTime.value == ""){
	   			alert("考核时间不能为空！");
	   			return true;
	   		}

	   		if(isNaN(form1.deductPoints.value)){
	   			alert("扣分必须位数字！");
	   			return true;
	   		}
	   	    
	   		if(form1.description.value.length > 4000){
   				alert("扣分描述不能超过4000个字！");
   				return true;
	   	    }
	   		return false;
	   }
	   
	   function showError(error){
		   alert(error);
	   }

	   function showInfo(info){
		   alert(info);
		   window.returnValue = "ok";
		   window.close();
	   }
	</script>
</head>
<body  rightmargin="0" bottommargin="0" leftmargin="0" topmargin="0" onclick="clickBody();" onload="init();">
	<form name="form1" action="assess_person_action.jsp" method="post" target="actionFrame">
	<input type="hidden" name="itemId" value="<%=itemId%>">
	<input type="hidden" name="actionType">
	<table class="dialogTable" cellpadding="0" cellspacing="0">
		<!-- 表头-->
		<tr class="dialogTableHeader">
			<td>队员考核</td>
		</tr>
		<!-- 表数据-->
		<tr class="dialogTableContent">
			<td>
				<!-- 数据项 -->
				<table class="dataTable">
					<col width="30%">
					<col width="70%">
					<tr>
						<td class="field">
							单位
						</td>
						<td>
							<span class="treeSpan" onclick="showTree(this, '../common/deptTree.jsp');" treeSelect="true">
								<input name="deptname" value="" style="width: 338px;" readonly="readonly" 
								treeSelect="true"><input name="deptId" value="" type="hidden">
							</span>
						</td>
					</tr>
					<tr>
						<td class="field">
							考核人员
						</td>
						<td>
							<span class="treeSpan" onclick="showTree(this, '../common/personTree.jsp');" treeSelect="true">
								<input name="personname" value="" style="width: 338px;" readonly="readonly" 
								treeSelect="true"><input name="personId" value="" type="hidden">
							</span>
						</td>
					</tr>
					<tr>
						<td  class="field">
							考核时间
						</td>
						<td>
							<input type="text" name="assessTime" style="width: 230px;cursor: hand;" id="time" onClick="return showCalendar(this.id, 'y-mm-dd');" readonly="readonly"><img 
									src="../../img/tip_calender.gif" style="cursor: hand;" width="16" height="16" onClick="return showCalendar('time', 'y-mm-dd');">
						</td>
					</tr>
					<tr>
						<td class="field">
							扣分
						</td>
						<td>
							<input name="deductPoints" style="width: 100%;" value="<%=deductPoints %>"/>
						</td>
					</tr>
					<tr style="height: 200px">
						<td class="field">
							扣分描述
						</td>
						<td>
							<textarea name="description" style="width: 100%;height: 100%"></textarea>
						</td>
					</tr>

				</table>
			</td>
		</tr>
		<tr>
			<td colspan="2" class="tableBtn">
				<span onclick="doSubmit();">确定</span>
				<span onclick="window.close();">取消</span>
			</td>
		</tr>
		<tr valign="top">
			<td colspan="2">
				&nbsp;
			</td>
		</tr>
	</table>
	</form>
	<iframe src="#" frameborder="0" id="treeFrame" name="frame" style="display: none;position: absolute;"></iframe>
	<iframe src="#" name="actionFrame" style="display: none;"></iframe>
</body>
</html>